const baseURL="http://localhost:8080/file/upload"
function upload(options) {
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: baseURL,
      filePath: options,
	  name: 'file',
      success: (res) => {
        if (res.statusCode === 200) {
			const str = res.data;
			let urlMatch = str.match(/"url":"(http[^"]+)"/);
			
			if (urlMatch && urlMatch[1]) {
			  resolve(urlMatch[1]) // 输出提取出的 URL
			} else {
			  reject("提取异常");
			}
        } else {
          // 可以添加错误处理逻辑
          reject(res.errMsg);
        }
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}
 
export default upload;